#include <stdlib.h>
#include <stdio.h>
#include "lsg_hashfile.h"

using namespace LSG;

int main(int argc, char * argv[])
{
    if (argc != 3)
    {
	printf("test_hashfile key value\n");
	return -1;
    }

    int k = atoi(argv[1]);
    int v = atoi(argv[2]);

    THashFile<int, int> hashfile("./0.idx", 1024, 1024);
    if(hashfile.Error()) {
	printf("init fail: %s\n", hashfile.ErrMsg());
	return -1;
    }

    int e = hashfile.Add(k, v);
    if(e < 0) {
	printf("Add [%d, %d] fail: %d\n", k, v, e);
    } else {
	printf("Add [%d, %d] ok\n", k, v);
    }

    int value;
    e = hashfile.Get(k, &value);
    if(e < 0) {
	printf("Get [%d] fail: %d\n", k, e);
	return -1;
    } else {
	printf("Get [%d] ok: %d\n", k, value);
    }

    return 0;
}
